package com.hnkywl.sts.dao.zjgl;

import com.hnkywl.sts.entity.zjgl.Yhsxmx;
import net.ruixin.orm.hibernate.SimpleHibernateTemplate;
import org.springframework.stereotype.Repository;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-6-6
 * Time: 下午4:10
 * To change this template use File | Settings | File Templates.
 */
@Repository
public class    YhsxmxDao extends SimpleHibernateTemplate<Yhsxmx, Long> {
    /**
     * 判断属性是否重复
     * @param id 银行授信明细id
     * @param propertyName 银行授信明细属性名
     * @param propertyValue 银行授信明细属性值
     * @return
     */
    public Boolean checkUnique(Long id, String propertyName,Object propertyValue) {
        String hql;
        if (propertyValue == null)
            return false;
        if(id == null){
            //修改检验
            hql = "from Yhsxmx where " + propertyName + " = ? ";
            return this.existsQuery(hql, propertyValue);
        }else{
            //新增检验
            hql = "from Yhsxmx where " + propertyName + " = ? and id <>?";
            return this.existsQuery(hql, propertyValue,id);
        }
    }

}
